package LawsonTransformJava.xref;

import java.io.IOException;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

/**
 * This class reads cross reference data from an Access DB and maps in memory for retrieval through the {@link xlate} method
 * @author edavis
 *
 */
public class XrefEmpStatus extends CrossRef {

	private final static String TABLE_NAME = "xEMPSTATUS";
	static final String XLATE_ERROR = "STS_ERROR";

	/**
	 * This constructor creates a {@link Statement} link to the Cross Reference DB and a {@link ResultSet}.
	 * It uses a @link TreeMap to maintain a key,value relationship.
	 * 
	 * @throws SQLException
	 */
	public XrefEmpStatus() throws SQLException, IOException {
		stmt = xref.getDataStatement();
		rslt = stmt.executeQuery("SELECT * FROM " + TABLE_NAME);
		super.XLATE_ERROR=XLATE_ERROR;
		while (rslt.next()) {
			// The following should get the appropriate column from the Xref Table
			String old = rslt.getString(1) + rslt.getString(2);
			String newX = rslt.getString(3);
			values.put(old, newX);
		}
		//Release the JDBC recourses
		super.close();
	}
}
